<?php
/**
 * 货到付款订单
 * Enter description here ...
 * @author nijn
 *
 */
class PayOfOffline extends CActiveRecordBehavior{

	public function afterSave($event) {
		$owner = $this->getOwner();
		if($owner->status == 'ST_FINISHED' && $owner->pay_type == 'offline') {
			$pay = new PaymentBill();
			if (is_object($owner->pay)) {
				$pay = $owner->pay;
			}
			$attributes = array(
				'payment_id' => $owner->id,
				'outer_order_id' => date('Ymd').time(),
				'user_id' => $owner->worker_id,
				'user_name' => CHtml::value($owner, 'member.profile.nickname'),
				'money' => CHtml::value($owner, 'total'),
				'pay_time' => date('Y-m-d H:i:s'),
				'status' => 1,
			);
			$pay->attributes = $attributes;
			$pay->save();
		}
	}
}

?>